package com.tianji.learning.controller;

import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.page.QuestionAdminPageQuery;
import com.tianji.learning.domain.vo.QuestionAdminVO;
import com.tianji.learning.domain.vo.QuestionVO;
import com.tianji.learning.service.IInteractionQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 管理端
 * </p>
 *
 * @author ffk
 * @since 2024-06-25
 */
@Api("管理端查询问题")
@RestController
@RequiredArgsConstructor
@RequestMapping("/admin/questions")
public class InteractionQuestionAdminController {

    private  final IInteractionQuestionService interactionQuestionService;

    /**
     * 管理员分页查询问题
     * @param pageQuery
     * @return
     */
    @ApiOperation("管理员分页查询问题")
    @GetMapping("page")
    public PageDTO<QuestionAdminVO> adminQueryPage(QuestionAdminPageQuery pageQuery){
        return interactionQuestionService.adminQueryPage(pageQuery);
    }


    /**
     * 管理员 根据问题id查询问题详情
     * @param id
     * @return
     */
    @ApiOperation("根据问题id查询问题详情")
    @GetMapping("/{id}")
    public QuestionAdminVO adminQueryById(@PathVariable("id") Long id){
        return interactionQuestionService.adminQueryById(id);
    }

    /**
     * 管理端 隐藏或显示问题
     */
    @ApiOperation("管理端-隐藏或显示问题")
    @PutMapping("/{id}/hidden/{hidden}")
    public void updateAdminQuestionHidden(@PathVariable("id") Long id, @PathVariable("hidden") Boolean hidden){
        interactionQuestionService.updateAdminQuestionHidden(id,hidden);
    }

}
